#include "glwidget.h"

CellObject* GLWidget::addSphere()
{
    CellObject *sphere = new CellObject();
    sphere->buildSphere(0.0, 0, 0);
    char num[10];
    sprintf(num, "%d", sphereNum);
    string n("sphere");
    n+=string(num);
    sphereNum++;
    sphere->setName(n);
    //objects.push_back(sphere);
    updateGL();
    return sphere;
}

CellObject *GLWidget::addCylinder()
{
    CellObject *cylinder = new CellObject();
    cylinder->buildCylinder(0.0, 0.0, 0, 0);
    char num[10];
    sprintf(num, "%d", cylinderNum);
    string n("cylinder");
    n+=string(num);
    cylinderNum++;
    cylinder->setName(n);
    //objects.push_back(cylinder);
    updateGL();
    return cylinder;
}

CellObject *GLWidget::addOpenCylinder()
{
    CellObject *cylinder = new CellObject();
    cylinder->buildOpenCylinder(0.0, 0.0, 0, 0);
    char num[10];
    sprintf(num, "%d", cylinderNum);
    string n("cylinder");
    n+=string(num);
    cylinderNum++;
    cylinder->setName(n);
    //objects.push_back(cylinder);
    updateGL();
    return cylinder;
}

CellObject *GLWidget::addCube()
{
    CellObject *cube = new CellObject();
    cube->buildCube(0.0, 0.0, 0.0, 0, 0, 0);
    char num[10];
    sprintf(num, "%d", cubeNum);
    string n("cube");
    n+=string(num);
    cubeNum++;
    cube->setName(n);
    //objects.push_back(cube);
    updateGL();
    return cube;
}

CellObject *GLWidget::addPlane()
{
    CellObject *plane = new CellObject();
    plane->buildPlane(0.0, 0.0, 0, 0);
    //objects.push_back(plane);
    updateGL();
    return plane;
}

CellObject *GLWidget::addCone()
{
    CellObject *cone = new CellObject();
    cone->buildCone(0.0 ,0.0, 0);
    //objects.push_back(cone);
    updateGL();
    return cone;
}

CellObject *GLWidget::addLine()
{
    CellObject *line = new CellObject();
    line->buildLine(0.0); //TODO
    //object.push_back(line);
    updateGL();
    return line;
}

void GLWidget::addObject(CellObject *obj)
{
    objects.push_back(obj);
    updateGL();
}

void GLWidget::addObject(CellObject *obj, int index)
{
    objects.insert(objects.begin()+index, obj);
    updateGL();
}
